package com.walnut.servlet;

import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/logout")
public class Logout extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取 ServletContext
        ServletContext context = getServletContext();

        // 移除 "loginer" 字段
        context.removeAttribute("loginer");
        context.removeAttribute("isAdmin");

        // 返回一个成功的响应
        response.setStatus(HttpServletResponse.SC_OK);
    }

}
